package cn.anlab.anappframe.demo.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;
import cn.anlab.anappframe.R;

public class HomeAdapter extends BaseAdapter {
	
	private Context context;
	private List<Map<String, String>> dataList;

	public HomeAdapter(Context context, List<Map<String, String>> dataList) {
		this.context = context;
		this.dataList = dataList;
	}
	
	
	@Override
	public int getCount() {
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		return dataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View itemView = inflater.inflate(R.layout.demo_home_menu_item, null);
		TextView tv = (TextView)itemView.findViewById(R.id.home_menu_item_txt);
		Map<String, String> map = (Map<String, String>)getItem(position);
		tv.setText(map.get("name"));
		return itemView;
	}

}
